<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 1数组转换为字符串
      var arr = ['齐', '楚', '燕', '韩', '赵', '魏', '秦'];
      // 1.1 toString()
      console.log(arr.toString()); //齐,楚,燕,韩,赵,魏,秦
      // 1.2 数组 join(分隔符)   如果没有写分隔符的话默认就是逗号  齐,楚,燕,韩,赵,魏,秦
      console.log(arr.join()); // 齐,楚,燕,韩,赵,魏,秦
      console.log(arr.join('-')); //齐-楚-燕-韩-赵-魏-秦

      //    2. 合并2个数组
      var arr1 = [11, 22];
      var arr2 = [33, 44];
      //合并arr1和arr2
      var arr3 = arr1.concat(arr2);
      console.log(arr3); //11,22,33,44



      // 高级玩法  合并数组  ... 展开运算符
      var arr4 = [...arr1, ...arr2];
      console.log(arr4); //11,22,33,44

      //3.切割数组 slice
       var arr10=['齐', '楚', '燕', '韩', '赵', '魏', '秦']
       var arr11= arr10.slice(1,4)
       console.log(arr11);   // ["楚", "燕", "韩"]

   //4. splice 删除元素
   // 数组.splice  (开始删除的下标, 删除几项,  补位填充元素)
   //4.1  基本删除 
   var arr5= ['齐', '楚', '燕', '韩', '赵', '魏', '秦']
     arr5.splice(4,2)
     console.log(arr5);   // ["齐", "楚", "燕", "韩", "秦"]

   //4.2 删除后补位 
   var arr6 = [1,56,76,345,875,234,6,55,678]
   arr6.splice(1,5,888,888,888,888,888,888,888,888,888)
   console.log(arr6); //[1, 888, 888, 888, 888, 888, 888, 888, 888, 888, 6, 55, 678]

   arr6.splice(5,1,arr)
   console.log(arr6);
   //console.log(arr6[5][0]);
    </script>
  </body>
</html>
